﻿using e_commerce.BLL.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace e_commerce.BLL.Services
{
    public class CommentManager
    {
        private commerceDbContext _dbContext;
        public CommentManager()
        {
            _dbContext = new commerceDbContext();
        }

        public IEnumerable<Comment> GetClientCommentById(int clientId)
        {
            return _dbContext.Comment.Where(c => c.ClientId == clientId);
        }

        public IEnumerable<Comment> GetCommentByPage(int page,int size)
        {
            var comment = (from c in _dbContext.Comment
                           orderby c.CommentTime
                           select c).Skip((page - 1) * size).Take(size);
            return comment;
        }

        public IEnumerable<Comment> GetNewComment(int count)
        {
            return _dbContext.Comment.OrderByDescending(c => c.CommentTime).Take(count);
        }
    }
}
